inRange <- function(x, a, b) {
  ifelse((x - a)  *  (b - x) >= 0 , 1, 0)
}